package com.wilschrader.demarche.units;

import com.wilschrader.demarche.Simulation;
import com.wilschrader.demarche.Unit;

/**
 * A carrier unit's primary purpose is to carry fighters and ground forces.
 * 
 * @author Wil Schrader
 * @modifications
 * 	08172011	Added new constructor that can be used to fill carriers with ground forces.
 * 	08152011	Updates for the unified unit class.
 * 
 */
public class Carrier extends Unit {
	
	public Carrier(int cost, int combatValue, Unit unit, int count) {
		super(Unit.Type.Carrier, cost, new int[]{combatValue}, new int[]{1}, 6, false);
		
		if (GROUND_UNITS.contains(unit.getType())) {
			Simulation.debugOutput("Adding " + count + " Ground Units to Unit (Carrier)");
			for (int i = 0; i < count; i++) {
				if (i < capacity) {
					try {
						Unit copiedUnit = unit.clone();
						activeUnits.add(copiedUnit);
					} catch (CloneNotSupportedException e) {
						e.printStackTrace();
					}
				}
			}
		} else {
			Simulation.debugOutput("Unit (Carrier) can only hold ground units.");
		}
	}
	
	public Carrier(int cost, int combatValue) {
		super(Unit.Type.Carrier, cost, new int[]{combatValue}, new int[]{1}, 6, false);
	}
	
	@Override
	public Carrier clone() throws CloneNotSupportedException {
		return new Carrier(cost, combatValue[0]);
	}
}
